package com.zmm.member.config;

import com.zmm.member.interceptor.MemberAuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.annotation.Resource;

/**
 * @Description:
 * @Name MyInterceptorConfig
 * @Author Zebulon
 * @Date By 2021-06-22 21:49:30
 */
@Configuration
public class MyInterceptorConfig extends WebMvcConfigurationSupport {

	@Resource
	private MemberAuthInterceptor memberAuthInterceptor;

	@Override
	protected void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(memberAuthInterceptor).addPathPatterns("/**").excludePathPatterns("/static/**");
		//super.addInterceptors(registry);
	}

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {

		//这是配置模板页面的路径  配置文件里面已经配置了  所以这里暂时不需要
		//这是是配置静态资源文件的路径
		registry.addResourceHandler("/static/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/");
		super.addResourceHandlers(registry);
	}
}
